{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-07-12T02:57:26.024139Z",
     "start_time": "2019-07-12T02:57:24.994878Z"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "data=pd.read_csv('D:\\百融去重处理\\去重百融_0711.csv')\n",
    "data['CREDIT_TIME']=pd.to_datetime(data.CREDIT_TIME,format='%Y-%m').dt.month\n",
    "city = ['无锡市','淮安市','中山市','东莞市','惠州市','重庆市辖区']\n",
    "mon  = [3,4,5,6]\n",
    "ab   = ['A','B']\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-07-12T03:03:55.688486Z",
     "start_time": "2019-07-12T03:03:54.643279Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "无锡市 , 4 , A , 6 , 344\n",
      "无锡市 , 4 , B , 8 , 857\n",
      "无锡市 , 5 , A , 3 , 695\n",
      "无锡市 , 5 , B , 9 , 1056\n",
      "无锡市 , 6 , A , 4 , 512\n",
      "无锡市 , 6 , B , 4 , 424\n",
      "淮安市 , 4 , A , 2 , 275\n",
      "淮安市 , 4 , B , 4 , 548\n",
      "淮安市 , 5 , A , 5 , 600\n",
      "淮安市 , 5 , B , 1 , 662\n",
      "淮安市 , 6 , A , 1 , 666\n",
      "淮安市 , 6 , B , 3 , 477\n",
      "中山市 , 4 , A , 5 , 166\n",
      "中山市 , 4 , B , 19 , 346\n",
      "中山市 , 5 , A , 10 , 422\n",
      "中山市 , 5 , B , 12 , 494\n",
      "中山市 , 6 , A , 4 , 275\n",
      "中山市 , 6 , B , 4 , 204\n",
      "东莞市 , 4 , A , 4 , 246\n",
      "东莞市 , 4 , B , 7 , 587\n",
      "东莞市 , 5 , A , 7 , 705\n",
      "东莞市 , 5 , B , 5 , 924\n",
      "东莞市 , 6 , A , 33 , 955\n",
      "东莞市 , 6 , B , 30 , 850\n",
      "惠州市 , 4 , A , 0 , 32\n",
      "惠州市 , 4 , B , 6 , 92\n",
      "惠州市 , 5 , A , 6 , 133\n",
      "惠州市 , 5 , B , 4 , 183\n",
      "惠州市 , 6 , A , 18 , 234\n",
      "惠州市 , 6 , B , 12 , 188\n",
      "重庆市辖区 , 4 , A , 10 , 259\n",
      "重庆市辖区 , 4 , B , 22 , 462\n",
      "重庆市辖区 , 5 , A , 21 , 645\n",
      "重庆市辖区 , 5 , B , 37 , 771\n",
      "重庆市辖区 , 6 , A , 15 , 647\n",
      "重庆市辖区 , 6 , B , 22 , 617\n"
     ]
    }
   ],
   "source": [
    "for i in city:\n",
    "    for j in mon:\n",
    "        for k in ab:\n",
    "            all = data.loc[(data['ACCEPT_CITY_NAME']==i)&(data['CREDIT_TIME']==j)&(data['RULE_FLOW_REMARK']==k)].copy()\n",
    "            if all.shape[0] !=0:\n",
    "                open = all.loc[all['STATUS7']=='OPEN'].copy()\n",
    "                open.drop_duplicates(subset=['CERT_NO_CIPHERTEXT'],keep='first',inplace=True)\n",
    "                all.drop_duplicates(subset=['CERT_NO_CIPHERTEXT'],keep='first',inplace=True)\n",
    "                print(i,',',j,',',k,',',open.shape[0],',',all.shape[0])\n",
    "                "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-07-12T02:46:11.884201Z",
     "start_time": "2019-07-12T02:46:11.874225Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['Unnamed: 0', 'MOBILE_NO', 'ACCOUNT_ID', 'CUSTOMER_NAME', 'CERT_NO',\n",
       "       'CERT_NO_CIPHERTEXT', 'REQUEST_DATE', 'STATUS', 'GRANT_AMOUNT',\n",
       "       'FAIL_REASON', 'ACTIVE_START_DATE', 'EDUCATION_DEGREE',\n",
       "       'MONTHLY_SALARY', 'DEBIT_BANK_NAME', 'FAIL_CODE', 'FACE_COMPARE_RESULT',\n",
       "       'FAIL_STEP', 'EVENT_TYPE', 'CERT_EFFECTIVE_START_DATE',\n",
       "       'CERT_EFFECTIVE_END_DATE', 'CERT_FRONT_GROUP_NAME',\n",
       "       'CERT_FRONT_FILE_NAME', 'CERT_REVERSE_GROUP_NAME',\n",
       "       'CERT_REVERSE_FILE_NAME', 'FACE_GROUP_NAME', 'FACE_FILE_NAME',\n",
       "       'REQUEST_SYSTEM', 'CFG_STATUS', 'RULE_NAME', 'IS_MAIN_RULE',\n",
       "       'ZIYINGA_SCORE', 'ZIYINGB_SCORE', 'RULE_FLOW_REMARK', 'CUSTOMER_AGE',\n",
       "       'SALE_CLERK_PROVINCE_CODE', 'SALE_CLERK_CITY_CODE', 'IR_ALLMATCH_DAYS',\n",
       "       'IR_ID_X_CELL_NOTMAT_DAYS', 'IR_ID_X_CELL_LASTCHG_DAYS',\n",
       "       'IR_ID_X_MAIL_CNT', 'IR_CELL_X_MAIL_CNT', 'IR_ID_X_CELL_CNT',\n",
       "       'IR_M12_CELL_X_NAME_CNT', 'IR_M12_ID_X_DEVICE_CNT',\n",
       "       'IR_M1_CELL_X_ID_CNT', 'IR_M1_ID_X_CELL_CNT',\n",
       "       'IR_M12_ID_X_BIZ_WORK_CNT', 'CF_PROB_MIN', 'CF_CONS_CONS_NUMS',\n",
       "       'CF_CONS_NOCONS_NUMS', 'CF_CONS_C15_VIEWS', 'CF_CONS_C9_VIEWS',\n",
       "       'TL_M1_ID_NOBANK_ALLORGNUM', 'TL_M1_ID_NOBANK_NEWALLNUM',\n",
       "       'TL_M1_CELL_NOBANK_PASSNUM', 'STAB_ADDR_NUM', 'STAB_AUTH_KEY_RELATION',\n",
       "       'ZHENGXIN_BODY', 'IS_BLACK', 'OPERATOR', 'BILLINGCHARGE', 'MONETARY',\n",
       "       'NETWORKTIME', 'NETWORKTIME_MONTH', 'SCORE', 'SCORE_REASON',\n",
       "       'COMPLETE_TIME', 'ACCEPT_CITY_NAME', 'SEASON4', 'STATUS4',\n",
       "       'REPAY_TIME4', 'SEASON5', 'STATUS5', 'REPAY_TIME5', 'SEASON6',\n",
       "       'STATUS6', 'REPAY_TIME6', 'SEASON7', 'STATUS7', 'REPAY_TIME7',\n",
       "       'CREDIT_BY', '二手单', 'CREDIT_TIME', 'D_MONTHLY_SALARY', 'IS_MARRIED',\n",
       "       'EDUCATIONDEGREE', 'INDUSTRY_CATEGORY', 'CSP', 'GRADUATION_DATE',\n",
       "       'D_DEBIT_BANK_NAME', 'EMERGANCY_FIRST_RELATIONSHIP',\n",
       "       'EMERGANCY_SECOND_RELATIONSHIP'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.columns"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
